home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* File subsystem -- Upload file *)
- (* *)
- (* Copyright 1988, 1989 by H. Roy Engehausen. All rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- {$O+}
-
- UNIT BBFSU;
-
- INTERFACE
-
- PROCEDURE upload_file_cmd(cmd_string : STRING);
-
- IMPLEMENTATION
-
- USES
- DOS,
- bbcopy,
- bbdummy,
- bbfin,
- bbfsm,
- bbmdata,
- bbmess,
- bbmisc,
- bbmisc5,
- bbsdata,
- bbstr;
-
- PROCEDURE upload_file_cmd(cmd_string : STRING);
-
- VAR
- code : INTEGER;
- dir_to_search : fsb_name_str;
- i : WORD;
- in_f : file_name_str;
- look : SEARCHREC;
- search_arg : file_name_str;
- this_fsb : fsb_ptr;
- this_msg : msg_index_ptr;
- word_count : BYTE;
-
- {$I BBFSI.PAS}
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* Parse command and execute right routine *)
- (*-----------------------------------------------------------------------*)
-
- IF cmd_string[2] <> ' ' THEN
- BEGIN;
- send_message(message_err_2nd);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- upcase_str_var(cmd_string);
-
- word_count := words(cmd_string);
-
- IF word_count <> 3 THEN
- BEGIN;
- IF word_count < 3 THEN
- send_message(message_not_en)
- ELSE
- send_message(message_err_wrd);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Parse *)
- (*-----------------------------------------------------------------------*)
-
- dir_to_search := subwordl(cmd_string, 2, SIZEOF(fsb_name_str) - 1);
-
- search_arg := subwordl(cmd_string, 3, SIZEOF(search_arg) - 1);
-
- (*-----------------------------------------------------------------------*)
- (* Find the directory *)
- (*-----------------------------------------------------------------------*)
-
- this_fsb := find_fsb(dir_to_search);
-
- IF (this_fsb = NIL) OR
- (active_tcb^.uid_data.user_class < this_fsb^.fsb_up) THEN
- BEGIN;
- send_message(message_no_files_one);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Check for subdirectory *)
- (*-----------------------------------------------------------------------*)
-
- IF (POS('\', search_arg) > 0) AND this_fsb^.fsb_f_subdir_ok THEN
- BEGIN;
- send_message(message_no_slash);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Check for wildcards *)
- (*-----------------------------------------------------------------------*)
-
- IF (POS('*', search_arg) > 0) THEN
- BEGIN;
- send_message(message_no_wild);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Build output file name *)
- (*-----------------------------------------------------------------------*)
-
- cmd_string := this_fsb^.fsb_path + search_arg;
-
- i := file_test(cmd_string);
-
- IF i = 0 THEN
- BEGIN;
- send_message(message_file_exists);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- IF i <> 2 THEN
- BEGIN;
- send_tnc_data_str(dos_err_message(i) + cr);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Build temp file name *)
- (*-----------------------------------------------------------------------*)
-
- in_f := opt_block.msg_file_dir + active_tcb^.port_chan_s + '.IN';
-
- (*-----------------------------------------------------------------------*)
- (* Tell user to start the file *)
- (*-----------------------------------------------------------------------*)
-
- send_message(message_send_the_file);
-
- (*-----------------------------------------------------------------------*)
- (* Receive the file *)
- (*-----------------------------------------------------------------------*)
-
- in_text_file(in_f, FALSE);
-
- IF active_tcb^.error_sw = TRUE THEN
- EXIT;
-
- (*-----------------------------------------------------------------------*)
- (* Copy file *)
- (*-----------------------------------------------------------------------*)
-
- cmd_string := copy_file_binary(in_f, cmd_string, FALSE);
-
- (*-----------------------------------------------------------------------*)
- (* Report any errors *)
- (*-----------------------------------------------------------------------*)
-
- IF cmd_string <> '' THEN
- BEGIN;
- send_tnc_data_str(cmd_string + cr);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END
- ELSE
- send_message(message_file_saved);
-
- END;
-
- END.